﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMS_Master.DTO.Personnel;
using TMS_Master.Personnel_module;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace TMS_Master
{
    public class InductionService :CrudAppService
       <Induction,
        InductionDTO,
        Guid,
        PagedAndSortedResultRequestDto,
       InductionDTOText>,
        IInductionService
    {
        public readonly IRepository<Induction, Guid> tMSApp;
        public InductionService(IRepository<Induction, Guid> _tMSApp) : base(_tMSApp)
        {
            tMSApp = _tMSApp;
        }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="Staff"></param>
        /// <returns></returns>
        public async Task<int> AddInduction(InductionDTO Induction)
        {
            Induction Add = ObjectMapper.Map<InductionDTO, Induction>(Induction);
            await tMSApp.InsertAsync(Add);
            return 1;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public async Task DelInduction(Guid Id)
        {
            await tMSApp.DeleteAsync(Id);
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public async Task<InductionDTO> FanInduction(Guid Id)
        {
            Induction b = await tMSApp.GetAsync(Id);
            InductionDTO fan = ObjectMapper.Map<Induction, InductionDTO>(b);
            return fan;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <returns></returns>
        public async Task<List<InductionDTO>> GetInduction()
        {
            List<Induction> p = await tMSApp.ToListAsync();
            List<Induction> becomes = p;
            List<InductionDTO> InductionDTOs = ObjectMapper.Map<List<Induction>, List<InductionDTO>>(becomes);
            return InductionDTOs;

        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="become"></param>
        /// <returns></returns>
        public async Task<int> UptInduction(InductionDTO become)
        {
            Induction e = await tMSApp.GetAsync(become.Id);
            e.InductionName = become.InductionName;
            return 1;
        }
    }
}
